<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>vue</title>
    <script src='../引入vue2.js'></script>
</head>

<body>
    <div id='app'>
        <input type="text" v-model="myText" />
        <ul>
            <li v-for="data in test()" :key="data">
                {{data}}
            </li>
        </ul>
        <!-- 支持函数表达式 -->
        <!-- {{test()}} -->
    </div>
</body>
<script>
    let vm = new Vue({
        el: '#app',
        data: {
            myText: "",
            list: ["aaa", "add", "bbb", "bbc", "ccc", "ddd", "eee", "ade"],
        },
        methods: {
            // 当状态变化时，和状态相关的函数也会触发
            test() {
                console.log('------------test---------');
                return this.list.filter(item => item.includes(this.myText));
            }
        }
    });
</script>

</html>